
    package com.heima.user.controller.v1;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.heima.apis.user.ApUserFansControllerApi;
import com.heima.model.media.dtos.WmNewsStatisticsDto;
import com.heima.model.user.pojos.ApUserFan;
import com.heima.user.service.ApUserFansService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/api/v1/user")
public class ApUserFansController implements ApUserFansControllerApi {

    @Resource
    private ApUserFansService apUserFansService;

    @Override
    @PostMapping("queryFansId")
    public List<Long> queryFansId(@RequestBody WmNewsStatisticsDto dto) {
        List<Long> collect = apUserFansService.list(
                Wrappers.<ApUserFan>lambdaQuery()
                        .eq(ApUserFan::getUserId, dto.getWmUserId())
                        .between(ApUserFan::getCreatedTime, dto.getStime(), dto.getEtime())
        ).stream().map(m -> {
            return m.getFansId();
        }).collect(Collectors.toList());
        return collect;
    }
}

